package com.linkstec;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

//import com.linkstec.redis.RedisUtil;

public class CalendarTest {

	private static final Logger logger = LogManager.getLogger();
	public static void main(String[] args) {
		Map<Integer, String> map = new HashMap<Integer, String>();
//		int str = Calendar.getInstance().get(Calendar.YEAR);
		map.put(2017, "fff");
		
		String str2 = map.get(Calendar.getInstance().get(Calendar.YEAR));

		logger.info(str2);
		int secondsNextEarlyMorning = getSecondsAfterTomorrowMorning();
		logger.info(secondsNextEarlyMorning);
//		RedisUtil.expired("", getSecondsNextEarlyMorning());
	}

	//获取到两天后凌晨1点到2点和现在相差的秒数
	public static int getSecondsAfterTomorrowMorning() {
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.DAY_OF_YEAR,2);
		cal.set(Calendar.HOUR_OF_DAY, 1);    
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.MILLISECOND, 0);
		logger.info(cal.getTime());
		Random r = new Random();
		int number = r.nextInt(3600)+1;
		logger.info(number);
		return (int)((cal.getTimeInMillis() - System.currentTimeMillis()) / 1000) + number;
		}
}